package com.wc._16届国特冲刺营._01暴力拆解.最小质因子之和_Hard_Version;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2025/5/22 8:01
 * @description
 * https://www.lanqiao.cn/courses/51805/learning/?id=4084021&compatibility=false
 */
public class Main {
    /**
     * 思路：
     * 使用ola筛在O(n)的时间复杂度将所有数的最小质数约束
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 20000010;
    static int[] primes = new int[N / 10];
    static boolean[] st = new boolean[N];
    static long[] sum = new long[N];
    static int n, cnt = 0;

    public static void main(String[] args) {
        ola(N - 1);
        for (int i = 1; i < N; i++) sum[i] += sum[i - 1];
        int T = sc.nextInt();
        while (T-- > 0) {
            n = sc.nextInt();
            out.println(sum[n]);
        }
        out.flush();
    }

    static void ola(int n) {
        st[0] = st[1] = true;
        for (int i = 2; i <= n; i++) {
            if (!st[i]) {
                primes[cnt++] = i;
                sum[i] = i;
            }

            for (int j = 0; primes[j] <= n / i; j++) {
                st[i * primes[j]] = true;
                sum[i * primes[j]] = primes[j];
                if (i % primes[j] == 0) break;
            }
        }
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}

